package com.xiexin.order.service.impl;

import com.xiexin.order.domain.Orders;
import com.xiexin.order.mapper.OrdersMapper;
import com.xiexin.order.service.IOrdersService;
import com.xiexin.orderset.mapper.OrdersettingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单Service业务层处理
 *
 * @author xiexin
 * @date 2022-04-05
 */
@Service
public class OrdersServiceImpl implements IOrdersService {
    @Autowired
    private OrdersMapper ordersMapper;

    @Resource
    private OrdersettingMapper ordersettingMapper;

    /**
     * 查询订单
     *
     * @param id 订单主键
     * @return 订单
     */
    @Override
    public Orders selectOrdersById(Long id) {
        return ordersMapper.selectOrdersById(id);
    }

    /**
     * 查询订单列表
     *
     * @param orders 订单
     * @return 订单
     */
    @Override
    public List<Orders> selectOrdersList(Orders orders) {
        return ordersMapper.selectOrdersList(orders);
    }

    /**
     * 新增订单
     *
     * @param orders 订单
     * @return 结果
     */

    @Override
    public int insertOrders(Orders orders) {
        // 添加订单后。  人数 改变
        int i = ordersMapper.insertOrders(orders);
        return  i;
    }
//    @Override
//    @Transactional
//    public int insertOrdersAndOrdersetting(Orders orders) {
//        // 添加订单后。  人数 改变
//        int i = ordersMapper.insertOrders(orders);
//        Date orderDate = orders.getOrderDate();
//        // 找到当天日期 加减
//        Ordersetting ordersetingByDate = ordersettingMapper.getOrdersetingByDate(orderDate);
//        System.out.println("查找到的当天的日期是ordersetingByDate = " + ordersetingByDate);
//        return  i;
//    }

    /**
     * 修改订单
     *
     * @param orders 订单
     * @return 结果
     */
    @Override
    public int updateOrders(Orders orders) {
        return ordersMapper.updateOrders(orders);
    }

    /**
     * 批量删除订单
     *
     * @param ids 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteOrdersByIds(Long[] ids) {
        return ordersMapper.deleteOrdersByIds(ids);
    }

    /**
     * 删除订单信息
     *
     * @param id 订单主键
     * @return 结果
     */
    @Override
    public int deleteOrdersById(Long id) {
        return ordersMapper.deleteOrdersById(id);
    }
}
